home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / my_audio.cpp < prev    next >
C/C++ Source or Header  |  1996-03-07  |  839b  |  48 lines

  1. #include "global.h"
  2.  
  3. // Audio includes...
  4. #include "audio.h"    
  5.  
  6. #include "defines.h"
  7. #include "front.h"    
  8. #include "eurofrnt\euro_int.h"
  9.  
  10. #include "externs.h"
  11.  
  12. extern match_data match_info;
  13.  
  14. extern float camera_x,camera_y,camera_z;
  15.  
  16. /*********************************/
  17. /*** Sound Fx Control Routines ***/
  18. /*********************************/
  19.  
  20. void play_fx(int fx,float x,float y)
  21. {
  22.     int pan,vol;
  23.     float d,xd,yd,zd;
  24.     xd=x-camera_x;
  25.     yd=y-camera_x;
  26.     zd=camera_z;
  27.  
  28.     d=calc_dist(x-camera_x,y-camera_y);
  29.     d=calc_dist(d,zd);
  30.     xd=xd/d;
  31.     yd=yd/d;
  32.     
  33.     if (d<MAX_VOL_DIST)
  34.         vol=0x7fff;
  35.     else
  36.         vol=(MAX_VOL_DIST/d)*0x7fff;
  37.  
  38.     d=((xd*cth)+(yd*sth));
  39.     pan=0x8000+(d*0x8000);
  40.  
  41.     if (EUROmatch_info.audio==2)
  42. // 3D Sound...
  43.         PlayPitchSample(fx,vol,pan);
  44.     else
  45. // Mono...
  46.         PlayPitchSample(fx,0x7fff,0x8000);
  47. }
  48.